<%= form_for(@scenario, :method => @scenario.new_record? ? "POST" : "PUT") do |f| %>
  <% if @scenario.errors.any? %>
    <div class="row well">
      <h2><%= pluralize(@scenario.errors.count, "error") %> 禁止保存这个场景:</h2>
      <% @scenario.errors.full_messages.each do |msg| %>
        <p class='text-warning'><%= msg %></p>
      <% end %>
    </div>
  <% end %>

  <div class="row">
    <div class="col-md-4">
      <div class="form-group">
        <%= f.label :name,"名称" %>
        <%= f.text_field :name, :class => 'form-control', :placeholder => "给你的场景起个名字" %>
      </div>
    </div>
    <div class="col-md-2">
      <div class="form-group">
        <%= f.label :tag_bg_color,"标签背景色" %>
        <%= f.color_field :tag_bg_color, :class => 'form-control', :value => @scenario.tag_bg_color || default_scenario_bg_color %>
      </div>
    </div>
    <div class="col-md-2">
      <div class="form-group">
        <%= f.label :tag_fg_color,"标签前景色" %>
        <%= f.color_field :tag_fg_color, :class => 'form-control', :value => @scenario.tag_fg_color || default_scenario_fg_color %>
      </div>
    </div>
  </div>

  <div class="row">
    <div class="col-md-8">
      <div class="form-group">
        <%= f.label :description,"可选的描述" %>
        <%= f.text_area :description, :rows => 10, :class => 'form-control', :placeholder => "可选描述是用来介绍该场景是做什么的，如果它是公开的，最好加入联系信息." %>
      </div>

      <div class="checkbox">
        <%= f.label :public,"公开" do %>
          <%= f.check_box :public %> 公开分享这个场景
        <% end %>
        <span class="glyphicon glyphicon-question-sign hover-help" data-content="如果选择了这个选项，这个场景和其中的机器人将全部公开。一个导出链接将分享给其他Huginn用户，请注意不要在这些机器人中使用私密认证信息，可以使用认证功能代替。"></span>
      </div>

    </div>
  </div>

  <div class="row">
    <div class="col-md-4">
      <div class="form-group">
        <div>
          <%= f.label :icon,"图标" %>
          <%= f.select(:icon, options_for_select(Scenario.icons), {},
            {:style => "font-family:'FontAwesome', Arial;", :class => 'select2-fountawesome-icon'}) %>
        </div>
      </div>
    </div>
  </div>

  <div class="row">
    <div class="col-md-4">
      <div class="form-group">
        <div>
          <%= f.label :agents,"代理" %>
          <%= f.select(:agent_ids,
                       options_for_select(current_user.agents.pluck(:name, :id), @scenario.agent_ids),
                       {}, { :multiple => true, :size => 5, :class => 'select2-linked-tags form-control', data: {url_prefix: '/agents'} }) %>
        </div>
      </div>
    </div>
  </div>

  <div class="row">
    <div class="col-md-12">
      <div class='form-actions' style='clear: both'>
        <%= f.submit "保存", :class => "btn btn-primary" %>
      </div>
    </div>
  </div>
<% end %>
